Repository navigation
[client-v2] Fix reading Dynamic values that hold an unnamed tuple - #3385
Open
Indian-boult wants to merge 1 commit into
Open
Indian-boult wants to merge 1 commit into
Indian-boult wants to merge 1 commit into
Conversation
The binary type encoding of a tuple without element names starts with tag 0x1F, which is also the tag of ClickHouseDataType.Tuple. readDynamicData found it in binTag2Type and used the default branch of the switch. That branch returned a bare Tuple column and left the element count and the element types in the stream, so the rest of the row was read from the wrong bytes. Send 0x1F to the tuple branch that already reads the named tuple tag 0x20. The value is now an Object[], the same as for a named tuple. Closes ClickHouse#3384
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
Dynamicvalue whose type has a tuple without element names, such asTuple(Int32, String)orArray(Tuple(Int32, String)), could not be read. The tag of such a tuple is0x1F, which is also the tag ofClickHouseDataType.Tuple.readDynamicDatafound it inbinTag2Typeand returned a bareTuplecolumn without reading the element count and the element types. The rest of the row was then read from the wrong bytes. The read failed withMissing nested data typeorUnsupported data type with tag 97, or it returned wrong values or no rows.Now
0x1Fgoes to the tuple branch that already reads named tuples. The value is anObject[], the same as for a named tuple. Values that already worked are read as before.Closes #3384
Checklist
Note
Medium Risk
Touches core binary deserialization for
Dynamictypes; wrong logic could misdecode rows, but the change is narrow and heavily tested.Overview
Fixes client-v2 / jdbc-v2 decoding when a
Dynamiccolumn’s runtime type includes unnamed tuples (e.g.Tuple(Int32, String), nested tuples, arrays/maps/variants of those types).readDynamicDatano longer treats binary tag0x1Fas a plainTupletype frombinTag2Typeand stopping early. It now routesTuple-tagged encodings into the same branch as named tuples, so element count and nested type encodings are consumed before values are read—keeping the stream aligned with the rest of the row.Values decode as
Object[], consistent with named tuples. Unit and integration tests cover nested unnamed tuples, nullable fields, arrays, maps, variants, and JSON; changelog #3384 documents the prior mis-read symptoms (wrong bytes, missing nested types, EOF).Reviewed by Cursor Bugbot for commit a989f2d. Bugbot is set up for automated code reviews on this repo. Configure here.